package com.zyz.C_数组;

/**
 * @author: vick
 * @Date: 2025/3/13
 * @Description:
 * @version: 1.0
 */
public class Demo {
    public static void main(String[] args) {
        //静态初始化
        int[] nums = {1, 2, 3, 4, 5};

        System.out.println(nums[0]);//第一个元素
        nums[0] = 11; //修改元素
        System.out.println(nums[0]);//第一个元素

        //动态初始化
        String[] fruits = new String[3];
        fruits[0] = "苹果";
        fruits[1] = "香蕉";

        //通过索引获取数组的值
        System.out.println(fruits[0]);
        System.out.println(fruits[1]);
        System.out.println(fruits[2]);

        System.out.println("数组长度：" + fruits.length);

        System.out.println("==数组的遍历==");
        for (int i = 0; i < fruits.length; i++) {
            System.out.println(fruits[i]);
        }
    }
}
